/**
 * This software implements a CAT-1 LTE baseband.
 *
 * global.h --
 *
 * Copyright (C) 2015  Optimum Semiconductor Technologies, Inc. info@optimumsemi.com

 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.

 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */

/* scaling for input bits */
#define INPUT_BITS      5
#define LG2SCALE	(INPUT_BITS - 1)
#define SCALE		(1<<LG2SCALE)
#define IFROMFP(f)	((int)((f)*SCALE))
#define ITOFP(i)	((double)(i)/(double)SCALE)


#define SHRT_MIN_2	(SHRT_MIN>>1)

// should be a multiple of WINDOW_SIZE
#define MAX_INPUTS 6400 //(5212)

/* sliding window sizes */
#define WINDOW_SIZE (256)
#define WINDOW_LEARN_SIZE (32)

/* number of bits between rescaling in alpha/beta computation */
#define RESCALE_INTERVAL (WINDOW_SIZE)


//#define INPUT_TYPE signed char
//#define INPUT_TYPE short

#define MAX2(x,y)	((x)>(y)?(x):(y))
#define MIN2(x,y)	((x)>(y)?(y):(x))

#define SCALE_LE(_x) ((3 * _x) >> 2)

#define SAT8(_x) (_x > 127 ? 127 : (_x < -128 ? -128 : _x))

#define SAT16(_x) _x > 0x7FFF ? 0x7FFF : (_x < -0x8000 ? -0x8000 : _x)


#if(PRINTOUT==1)
    #define PRINT(x) x
#else
    #define PRINT(x)
#endif

#if(CYCLE_COUNT==1)
    #define GET_CYC(_x) _x = __sb_cfsr(243)
#else
    #define GET_CYC(_x)
#endif

#if(GCC==0)
    #define PFUNC __putstring
#else
    #define PFUNC printf
#endif


extern int print_vals;

void make_interleave(int K_bits, unsigned short	output[]);




